Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
HTTP 429 handling and retry validation internal/auth/uat_client.go, internal/auth/uat_client_refresh_test.go |
refreshOnce handles HTTP 429 before decoding the response body and preserves the stored refresh token. Tests cover plain-text and JSON rate limits, a rate limit after an uncertain transport failure, and a successful retry that stores the rotated refresh token. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: 
Minimal · up to ec7ba
-
The HTTP 429 handling has no identified merge-blocking issue; proceed with normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix(auth): preserve refresh tokens on HTTP 429" names the main change: HTTP 429 responses from the token endpoint no longer cause the stored refresh token to be cleared. The changeset classifies 429 before body decoding and returns a retryable api/rate_limit error, and the tests cover that behavior. The title is short, specific, and follows a conventional-commit style.
Full details: Description check
-
Explanation
The description follows the repository template. It has a Summary that states the motivation and scope, a Changes list, a Test Plan with checklist items, and a Related Issues section that links
#2869,#2865,#2860, and#2840. The Test Plan records which checks ran and which did not, including the unchecked full unit-test run and the live tenant refresh. The template's Test Plan asks for a manual lark-cli verification item. The description does not include that item, and the author does not explain its absence. This is a minor gap because the description is otherwise complete.
Full details: Out of Scope Changes check
-
Explanation
The reported changes are limited to
internal/auth/uat_client.goandinternal/auth/uat_client_refresh_test.go. The implementation supports HTTP 429 classification. The test helper, regression cases, retry-rotation case, uncertain-refresh control, and comments support the linked refresh behavior. No unrelated change is reported.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.
-
Full details: Linked Issues check
-
Explanation
[
#2869] is met for HTTP 429. The PR summary states thatrefreshOnceclassifies HTTP 429 before body decoding, returns a retryableapi/rate_limiterror, and usesrefreshRetryAndPreserve. The reported tests cover plain-text and JSON 429 responses, retry success, and the uncertain-refresh control. [#2865] is only partially met. Its expected behavior also requires retryable preservation for every HTTP 5xx response, with or without a JSON body. The PR states that HTTP 5xx handling remains unchanged and does not report 5xx implementation or regression coverage.Resolution
Implement the
#2865HTTP 5xx requirement inrefreshOncebefore body decoding. Return the existing preserve action with a retryable error for status codes 500 and higher. Add plain-text and JSON 5xx regression cases that verify token preservation and the returned error classification. Keep the existing uncertain-outcome behavior unchanged.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
|
Adding another anonymized reproduction from lark-cli v1.0.98 on macOS with Keychain storage. Two isolated user configurations each encountered two consecutive HTTP 429 responses from /oauth/v3/token, less than 100 ms apart. Afterward, auth status reported the stored token as missing. The refresh tokens were still within their validity windows. We did not capture stderr or response bodies, so we cannot confirm which token-clearing path was triggered. PR #2875 appears to address token preservation on HTTP 429. However, immediate retries remain unchanged. Would it make sense to track bounded backoff with Retry-After support as a separate follow-up, without blocking this PR? Tests could cover repeated 429s, missing or malformed Retry-After, and cancellation during the wait. Our current workaround is to stagger initial refresh calls across configurations. |
|
@YingzuoLiu Thanks for the additional reproduction. It is consistent with the symptom this patch targets, though without stderr or response bodies we cannot identify which clearing path was taken. Agreed that bounded backoff and The follow-up should cover repeated 429s, valid/missing/malformed |
Retain linye157's original HTTP 429 token-preservation commits. This dependency is not part of the independent backoff implementation. Keep the follow-up draft until larksuite#2875 merges.
|
Another reproduction on npm The stored login was deleted 3 times in 6 days. Each time it was a single refresh that got two 429s from In the same week there were 4 other refreshes where a single 429 was followed by a 200 on the retry (11/05 07:05, 11/06 18:44, 11/07 13:23, 11/10 10:46), and the login survived those. One more data point on the impact: As far as I can tell, checking |
|
Another data point in support of this fix: we run lark-cli under a background daemon on employees' Macs (brand
We checked v1.0.100: In the meantime we added a check on our side that tells the user when their login disappears, but keeping the token is the real fix. |
|
Follow-up: this still happens on v1.0.100, the latest release (2026-11-10). That release does not include this PR, and The 4th deletion here had the same shape. A single refresh got two 429s 0.28 s apart, and That makes 4 deletions in 8 days (11/05, 11/08, 11/10, 11/12) for one user. Each one stops our scheduled jobs that use user identity until someone approves a new device flow. This time that took about 2 hours. Any chance this PR could make the next release? |
|
Thanks for documenting the v1.0.100 recurrence, @yonedanorikuni0118.
Two 429 responses followed by the login being removed while the
refresh token still had seven days left is the failure pattern #2875
is intended to handle. The patch preserves the stored login when both
attempts return 429 and there was no earlier uncertain refresh.
Bounded `Retry-After` handling is tracked in the dependent draft
#2881. #2875 is still open, so there is no release date I can confirm.
…On Thu, 12 Nov 2026 01:37:38 -0800, NORY ***@***.***> wrote:
yonedanorikuni0118 left a comment (larksuite/cli#2875)
Follow-up: this still happens on v1.0.100, the latest release (2026-11-10). That release does not include this PR, and `refreshOnce` in v1.0.100 still parses the body before checking `resp.StatusCode`.
The 4th deletion here had the same shape. A single refresh got two 429s 0.28 s apart, and `refreshExpiresAt` was still 7 days away:
```
2026-11-12T14:21:42.911+09:00 path=/oauth/v3/token status=429 (lark-cli base +record-list ...)
2026-11-12T14:21:43.192+09:00 path=/oauth/v3/token status=429
```
That makes 4 deletions in 8 days (11/05, 11/08, 11/10, 11/12) for one user. Each one stops our scheduled jobs that use user identity until someone approves a new device flow. This time that took about 2 hours.
Any chance this PR could make the next release?
--
Reply to this email directly or view it on GitHub:
#2875 (comment)
You are receiving this because you authored the thread.
Message ID: ***@***.***>
|
Summary
A token-endpoint HTTP 429 can delete an otherwise usable stored login: plain-text responses enter the invalid-JSON retry-and-clear path, while JSON responses with an unknown code stop and clear immediately. Recognize HTTP 429 before reading or decoding the body, and use the existing bounded retry-and-preserve action.
Changes
api/rate_limiterror with HTTP code 429.Scope and limitations:
Test Plan
Validation of the original functional patch (before this comment-only follow-up):
go test -race ./internal/auth ./internal/credential ./internal/identitydiag ./cmd/auth -count=1authentication/token_missing; both pass with this change.go mod tidy(no module changes), pinned golangci-lint (0 issues), source guards, lint-module tests, and license check pass. Build/vet useGOFLAGS=-buildvcs=falsebecause Go VCS discovery fails in this worktree.make unit-test: 126 packages pass; eight fail. Two additional failures are worktree VCS discovery ininternal/qualitygate/deptestandextension/command; both pass when rerun withGOFLAGS=-buildvcs=false. The remaining six packages have the same 31 failing test names as the checked base: Unix-socket restrictions, protected/rootpaths, and external DNS.GetValidAccessToken, retries, typed errors, and the isolated credential store through a scripted HTTP transport.Follow-up validation:
git diff --checkpasses.Related Issues
Summary by CodeRabbit